package eight.test_8_1;

import java.util.Scanner;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long count = 0;
        for (int i = 0; i < n; i++) {
            long tmp = scanner.nextLong();
            if(i == 0) {
                count = tmp;
            }
            if(count > tmp) {
                while (count > tmp) {
                    tmp *= 2;
                }
            } else if (count < tmp){
                while (count < tmp) {
                    count *= tmp;
                }
            }
            if(count != tmp) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}
